<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/file-upload.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/form/FileUploadField.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript" src="../../scripts/selectMeasureSpecification.js">
        </script>
        <script type="text/javascript">
            var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
			var pwfMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productworkflow');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
			var fcMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.francecustomer');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
            
            var ctYesnoXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtYesno');
            var ctCostumeTypeXmlLoader = new xmlLoader('../../servlet/CodeTableServlet?name=CtCostumeType');
			
			var idValue = getPrarmeterValue(window.location, 'id');
			var piIdValue = getPrarmeterValue(window.location, 'piId');
            var startPage = getPrarmeterValue(window.location, 'startPage');
			  
            var ctYesnoStore = new Ext.data.Store({
                reader: new Ext.data.XmlReader({
                    record: 'item',
                    id: 'code',
                    totalRecords: 'itemTotal'
                }, ['code', 'description']),
                data: ctYesnoXmlLoader.getXml()
            });
            
            var isDesignChartFinishedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isdesignchartfinished'),
                id: 'isDesignChartFinished',
                name: 'isDesignChartFinished',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isConfirmedByFactoryCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isconfirmedbyfactory'),
                id: 'isConfirmedByFactory',
                name: 'isConfirmedByFactory',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isConfirmedByCustomerCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isconfirmedbycustomer'),
                id: 'isConfirmedByCustomer',
                name: 'isConfirmedByCustomer',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isPricedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.ispriced'),
                id: 'isPriced',
                name: 'isPriced',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isConfirmedByDzCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isconfirmedbydz'),
                id: 'isConfirmedByDz',
                name: 'isConfirmedByDz',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isProcurementFinishedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isprocurementfinished'),
                id: 'isProcurementFinished',
                name: 'isProcurementFinished',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isProduceFinishedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isproducefinished'),
                id: 'isProduceFinished',
                name: 'isProduceFinished',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isPackageFinishedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.ispackagefinished'),
                id: 'isPackageFinished',
                name: 'isPackageFinished',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
			
			var isAllFinishedCombo = new Ext.form.ComboBox({
                fieldLabel: pwfMessage.get('ui.productworkflow.isallfinished'),
                id: 'isAllFinished',
                name: 'isAllFinished',
                editable: false,
                store: ctYesnoStore,
                valueField: 'code',
                displayField: 'description',
                triggerAction: 'all',
                emptyText: message.get('message.combo.pleaseselect'),
                selectOnFocus: true,
                mode: 'local'
            });
            
            Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                var piXMLReader = new Ext.data.XmlReader({
                    record: 'item'
                }, [{
                    name: 'id',
                    mapping: 'id'
                }, {
                    name: 'ctProductFamily',
                    mapping: 'ctProductFamily'
                }, {
                    name: 'ctMachineType',
                    mapping: 'ctMachineType'
                }, {
                    name: 'type',
                    mapping: 'type'
                }, {
                    name: 'orderNumber',
                    mapping: 'orderNumber'
                }, {
                    name: 'yarnNumber',
                    mapping: 'yarnNumber'
                }, {
                    name: 'ctDesignType',
                    mapping: 'ctDesignType'
                }, {
                    name: 'style',
                    mapping: 'style'
                }, {
                    name: 'customerLinkman',
                    mapping: 'customerLinkman'
                }, {
                    name: 'model',
                    mapping: 'model'
                }, {
                    name: 'ctSeasonNumber',
                    mapping: 'ctSeasonNumber'
                }, {
                    name: 'reference',
                    mapping: 'reference'
                }, {
                    name: 'createDate',
                    mapping: 'createDate'
                }, {
                    name: 'ctVersion',
                    mapping: 'ctVersion'
                }, {
                    name: 'patronageNumer',
                    mapping: 'patronageNumer'
                }, {
                    name: 'front',
                    mapping: 'front'
                }, {
                    name: 'back',
                    mapping: 'back'
                }, {
                    name: 'sleeves',
                    mapping: 'sleeves'
                }, {
                    name: 'bottomThrum',
                    mapping: 'bottomThrum'
                }, {
                    name: 'sleevesThrum',
                    mapping: 'sleevesThrum'
                }, {
                    name: 'necklineThrum',
                    mapping: 'necklineThrum'
                }, {
                    name: 'needle',
                    mapping: 'needle'
                }, {
                    name: 'weight',
                    mapping: 'weight'
                }, {
                    name: 'comment',
                    mapping: 'comment'
                }, {
                    name: 'customerID',
                    mapping: 'customerID'
                }, {
                    name: 'photoName',
                    mapping: 'photoName'
                }, {
                    name: 'chartName',
                    mapping: 'chartName'
                }, {
                    name: 'biMeasureSpecificationId',
                    mapping: 'biMeasureSpecificationId'
                }, {
                    name: 'biMeasureSpecificationName',
                    mapping: 'biMeasureSpecificationName'
                }, {
                    name: 'yarnName',
                    mapping: 'yarnName'
                }, {
                    name: 'frontPhotoName',
                    mapping: 'frontPhotoName'
                }, {
                    name: 'backPhotoName',
                    mapping: 'backPhotoName'
                }, {
                    name: 'photoName',
                    mapping: 'photoName'
                }, {
                    name: 'chartName',
                    mapping: 'chartName'
                }, {
                    name: 'ctCollarType',
                    mapping: 'ctCollarType'
                }, {
                    name: 'customerName',
                    mapping: 'customerName'
                }, {
                    name: 'customerDepartment',
                    mapping: 'customerDepartment'
                }]);
                
                var piXmlLoader = new xmlLoader('../../servlet/ProductIdentificationServlet?action=11&id=' + idValue);
                
                var piRecord = piXMLReader.readRecords(piXmlLoader.getXml()).records[0];
                
                var itemTplMarkup = ['<table cellspacing="0" id="the-table" style="width: 100%;"><tbody>',
										 '<tr><td style="background:#eeeeee; width: 15%;">',
										 message.get('message.list.id'), '</td><td>{id}</td>', 
										 '<td style="background:#eeeeee;width: 15%;">', 
										 piMessage.get('ui.productidentification.style'), 
										 '</td><td>{style}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.seasonnumber'), 
										 '</td><td>{ctSeasonNumber}</td>', '<td style="background:#eeeeee;">', 
										 referenceMessage.get('ui.reference.reference'), 
										 '</td><td>{reference}</td></tr>', 
										 
										 
										 '<tr><td style="background:#eeeeee;">', 
										 message.get('message.edit.productfamily'), 
										 '</td><td>{ctProductFamily}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.patronagenumer'), 
										 '</td><td>{patronageNumer}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.chartversion'), 
										 '</td><td>{ctVersion}</td><td style="background:#eeeeee;">', 
										 piMessage.get('ui.productidentification.model'), 
										 '</td><td>{model}</td></tr>',
										 '<tr><td style="background:#eeeeee;">', 
										 referenceMessage.get('ui.reference.weight'), 
										 '</td><td>{weight}</td><td style="background:#eeeeee;">', 
										 message.get('message.edit.collar'), 
										 '</td><td>{ctCollarType}</td><td style="background:#eeeeee;">', 
										 fcMessage.get('ui.francecustomer.name'), 
										 '</td><td>{customerName}</td><td style="background:#eeeeee;">', 
										 fcMessage.get('ui.francecustomer.department'), 
										 '</td><td>{customerDepartment}</td></tr>',
										 
										 '<tr><td colspan="8">',
										 //'<img width="120" src="../../_temp/{frontPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 //'<img width="120" src="../../_temp/{backPhotoName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 '<img width="120" src="../../_temp/{chartName}"/>&nbsp;&nbsp;&nbsp;&nbsp;',
										 '<img width="120" src="../../_temp/{photoName}"/>',
										 '</td></tr>',
										 '</tbody></table>'];
                var itemTpl = new Ext.Template(itemTplMarkup);
                itemTpl.append('productIdentification', piRecord.data);
                
               
			   var pwfForm = new Ext.FormPanel({
                    labelAlign: 'left',
                    url: '../../servlet/ProductWorkFlowServlet?action=1',
                    frame: true,
                    title: pwfMessage.get('ui.productworkflow.edittitle'),
                    bodyStyle: 'padding:5px 5px 5px 5px;margin-top: 2px;',
                    width: '100%',
                    labelWidth: 100,
                    reader: new Ext.data.XmlReader({
                        record: 'item'
                    }, [{
                        name: 'id',
                        mapping: 'id'
                    }, {
                        name: 'piId',
                        mapping: 'piId'
                    }, {
                        name: 'isDesignChartFinished',
                        mapping: 'isDesignChartFinished'
                    },{
                        name: 'comment1',
                        mapping: 'comment1'
                    }, {
                        name: 'isConfirmedByFactory',
                        mapping: 'isConfirmedByFactory'
                    }, {
                        name: 'comment2',
                        mapping: 'comment2'
                    }, {
                        name: 'isConfirmedByCustomer',
                        mapping: 'isConfirmedByCustomer'
                    },{
                        name: 'comment3',
                        mapping: 'comment3'
                    },{
                        name: 'isPriced',
                        mapping: 'isPriced'
                    },{
                        name: 'comment4',
                        mapping: 'comment4'
                    }, {
                        name: 'isConfirmedByDz',
                        mapping: 'isConfirmedByDz'
                    }, {
                        name: 'comment5',
                        mapping: 'comment5'
                    }, {
                        name: 'isProcurementFinished',
                        mapping: 'isProcurementFinished'
                    }, {
                        name: 'comment6',
                        mapping: 'comment6'
                    }, {
                        name: 'isProduceFinished',
                        mapping: 'isProduceFinished'
                    }, {
                        name: 'comment7',
                        mapping: 'comment7'
                    }, {
                        name: 'isPackageFinished',
                        mapping: 'isPackageFinished'
                    }, {
                        name: 'comment8',
                        mapping: 'comment8'
                    }, {
                        name: 'isAllFinished',
                        mapping: 'isAllFinished'
                    }, {
                        name: 'comment9',
                        mapping: 'comment9'
                    }]),
                    items: [{
                        id: 'id',
                        name: 'id',
                        xtype: 'hidden'
                    }, {
                        id: 'piId',
                        name: 'piId',
                        xtype: 'hidden',
						value: piIdValue
                    }, {
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [isDesignChartFinishedCombo]
                        },{
                            columnWidth: .5,
                            layout: 'form',
                            items: [isConfirmedByFactoryCombo]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment1',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        },{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment2',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [isConfirmedByCustomerCombo]
                        }, {
                            columnWidth: .5,
                            layout: 'form',
                            items: [isPricedCombo]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment3',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        },{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment4',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [isConfirmedByDzCombo]
                        }, {
                            columnWidth: .5,
                            layout: 'form',
                            items: [isProcurementFinishedCombo]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment5',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        },{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment6',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [isProduceFinishedCombo]
                        }, {
                            columnWidth: .5,
                            layout: 'form',
                            items: [isPackageFinishedCombo]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment7',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        },{
                            columnWidth: .5,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment8',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: 1.0,
                            layout: 'form',
                            items: [isAllFinishedCombo]
                        }]
                    
                    },{
                        layout: 'column',
                        items: [{
                            columnWidth: 1.0,
                            layout: 'form',
                            items: [{
	                            fieldLabel: message.get('message.edit.comment'),
	                            name: 'comment9',
	                            xtype: 'textarea',
	                            maxLength: 1024,
	                            width: '90%',
	                            maxLengthText: message.get('message.edit.toolong')
	                        }]
                        }]
                    
                    }],
                    
                    buttons: [{
                        text: message.get('message.edit.save'),
                        handler: function(){
							document.getElementsByName('isDesignChartFinished')[0].value = isDesignChartFinishedCombo.getValue();
							document.getElementsByName('isConfirmedByFactory')[0].value = isConfirmedByFactoryCombo.getValue();
							document.getElementsByName('isConfirmedByCustomer')[0].value = isConfirmedByCustomerCombo.getValue();
							document.getElementsByName('isPriced')[0].value = isPricedCombo.getValue();
							document.getElementsByName('isConfirmedByDz')[0].value = isConfirmedByDzCombo.getValue();
							document.getElementsByName('isProcurementFinished')[0].value = isProcurementFinishedCombo.getValue();
							document.getElementsByName('isProduceFinished')[0].value = isProduceFinishedCombo.getValue();
							document.getElementsByName('isPackageFinished')[0].value = isPackageFinishedCombo.getValue();
							document.getElementsByName('isAllFinished')[0].value = isAllFinishedCombo.getValue();
                            if (pwfForm.getForm().isValid()) {
                                pwfForm.getForm().submit({
                                    method: 'post',
                                    success: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.successful'));
                                        if (idValue != null) {
											document.getElementById('id').value = idValue;
											pwfForm.getForm().load({
													url:'../../servlet/ProductWorkFlowServlet?action=3&id=' + idValue, 
													waitMsg:Ext.LoadMask.prototype.msg, 
													success: function(form, action){
													}
											});
										}
                                    },
                                    failure: function(form, action){
                                        messageTip.msg(message.get('message.tip'), message.get('message.edit.unsuccessful'));
                                    }
                                });
                            }
                        }
                    }, {
                        text: message.get('message.edit.cancel'),
                        handler: function(){
                            if (startPage != null) {
                                window.location = 'product_work_flow_list.html?startPage=' + startPage;
                            }
                            else {
                                window.location = 'product_work_flow_list.html';
                            }
                        }
                    }]
                });
				
				pwfForm.render('productWorkFlowForm');
				
				if (idValue != null) {
					document.getElementById('id').value = idValue;
					pwfForm.getForm().load({
							url:'../../servlet/ProductWorkFlowServlet?action=3&id=' + idValue, 
							waitMsg:Ext.LoadMask.prototype.msg, 
							success: function(form, action){
							}
					});
				}
            });
        </script>
    </head>
    <body>
        <div id="productIdentification">
        </div>
        <div id="productWorkFlowForm">
        </div>
    </body>
</html>
